package com.comcast.util;

import org.apache.commons.logging.Log;

import org.apache.commons.logging.LogFactory;

import weblogic.application.ApplicationException;
import weblogic.application.ApplicationLifecycleEvent;
import weblogic.application.ApplicationLifecycleListener;

import com.comcast.util.ObjectFactory;

public class CoreApplicationLifecycleListener extends ApplicationLifecycleListener {
	private Log log = LogFactory.getLog(CoreApplicationLifecycleListener.class);

	@Override
	public void preStart(ApplicationLifecycleEvent arg0) throws ApplicationException {
    	System.out.println("preStart...");
	}

	@Override
	public void postStart(ApplicationLifecycleEvent arg0) throws ApplicationException {
		System.out.println("Initializing Spring Context at postStart...");
		ObjectFactory.getBean("Log4jConfigurer");
	}

	@Override
	public void preStop(ApplicationLifecycleEvent applicationlifecycleevent)
        throws ApplicationException {
		System.out.println("Destroying Spring Context at preStop...");
        ObjectFactory.destroy();
    }

	@Override
	public void postStop(ApplicationLifecycleEvent applicationlifecycleevent)
        throws ApplicationException {
		System.out.println("postStop...");
    }
}